set(ODE_VERSION "@VERSION@")
set(ODE_VERSION_MAJOR "@VERSION_MAJOR@")
set(ODE_VERSION_MINOR "@VERSION_MINOR@")
set(ODE_VERSION_PATCH "@VERSION_PATCH@")

set(ODE_16BIT_INDICES @ODE_16BIT_INDICES@)
set(ODE_DOUBLE_PRECISION @ODE_DOUBLE_PRECISION@)
set(ODE_NO_BUILTIN_THREADING_IMPL @ODE_NO_BUILTIN_THREADING_IMPL@)
set(ODE_NO_THREADING_INTF @ODE_NO_THREADING_INTF@)
set(ODE_OLD_TRIMESH @ODE_OLD_TRIMESH@)
set(ODE_WITH_GIMPACT @ODE_WITH_GIMPACT@)
set(ODE_WITH_LIBCCD @ODE_WITH_LIBCCD@)
set(ODE_WITH_LIBCCD_BOX_CYL @ODE_WITH_LIBCCD_BOX_CYL@)
set(ODE_WITH_LIBCCD_CAP_CYL @ODE_WITH_LIBCCD_CAP_CYL@)
set(ODE_WITH_LIBCCD_CYL_CYL @ODE_WITH_LIBCCD_CYL_CYL@)
set(ODE_WITH_LIBCCD_CONVEX_BOX @ODE_WITH_LIBCCD_CONVEX_BOX@)
set(ODE_WITH_LIBCCD_CONVEX_CAP @ODE_WITH_LIBCCD_CONVEX_CAP@)
set(ODE_WITH_LIBCCD_CONVEX_CONVEX @ODE_WITH_LIBCCD_CONVEX_CONVEX@)
set(ODE_WITH_LIBCCD_CONVEX_CYL @ODE_WITH_LIBCCD_CONVEX_CYL@)
set(ODE_WITH_LIBCCD_CONVEX_SPHERE @ODE_WITH_LIBCCD_CONVEX_SPHERE@)
set(ODE_WITH_LIBCCD_SYSTEM @ODE_WITH_LIBCCD_SYSTEM@)
set(ODE_WITH_OPCODE @ODE_WITH_OPCODE@)
set(ODE_WITH_OU @ODE_WITH_OU@)

@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/ode-export.cmake")

set(ODE_DEFINITIONS "")
set(ODE_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
set(ODE_LIBRARY_DIR "${PACKAGE_PREFIX_DIR}/lib")

macro(select_library_location target basename)
	if(TARGET ${target})
		foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_IMPLIB)
			get_target_property(${basename}_${property}_DEBUG ${target} ${property}_DEBUG)
			get_target_property(${basename}_${property}_MINSIZEREL ${target} ${property}_MINSIZEREL)
			get_target_property(${basename}_${property}_RELEASE ${target} ${property}_RELEASE)
			get_target_property(${basename}_${property}_RELWITHDEBINFO ${target} ${property}_RELWITHDEBINFO)
			
			if(${basename}_${property}_DEBUG AND ${basename}_${property}_RELEASE)
				set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELEASE})
			elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_RELWITHDEBINFO)
				set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_RELWITHDEBINFO})
			elseif(${basename}_${property}_DEBUG AND ${basename}_${property}_MINSIZEREL)
				set(${basename}_LIBRARY debug ${${basename}_${property}_DEBUG} optimized ${${basename}_${property}_MINSIZEREL})
			elseif(${basename}_${property}_RELEASE)
				set(${basename}_LIBRARY ${${basename}_${property}_RELEASE})
			elseif(${basename}_${property}_RELWITHDEBINFO)
				set(${basename}_LIBRARY ${${basename}_${property}_RELWITHDEBINFO})
			elseif(${basename}_${property}_MINSIZEREL)
				set(${basename}_LIBRARY ${${basename}_${property}_MINSIZEREL})
			elseif(${basename}_${property}_DEBUG)
				set(${basename}_LIBRARY ${${basename}_${property}_DEBUG})
			endif()
		endforeach()
	endif()
endmacro()

select_library_location(ODE::ODE ODE)

set(ODE_INCLUDE_DIRS ${ODE_INCLUDE_DIR})
set(ODE_LIBRARIES ${ODE_LIBRARY})
set(ODE_LIBRARY_DIRS ${ODE_LIBRARY_DIR})

include(CMakeFindDependencyMacro)

if(ODE_WITH_LIBCCD_SYSTEM)
	find_dependency(ccd)
	list(APPEND ODE_LIBRARIES ${CCD_LIBRARIES})
	list(APPEND ODE_LIBRARY_DIRS ${CCD_LIBRARY_DIRS})
endif()
